# 抽象产品类：计算机
class Computer:
    def launch(self):
        pass

# 具体产品类：MacBook
class MacBook(Computer):
    def launch(self):
        print("Launching MacBook")

# 具体产品类：MIBook
class MIBook(Computer):
    def launch(self):
        print("Launching MIBook")

# 抽象产品类：手机
class Phone:
    def launch(self):
        pass

# 具体产品类：IPhone
class IPhone(Phone):
    def launch(self):
        print("Launching IPhone")

# 具体产品类：MIPhone
class MIPhone(Phone):
    def launch(self):
        print("Launching MIPhone")

# 抽象工厂类
class AbstractFactory:
    def phone(self):
        pass

    def computer(self):
        pass

# 具体工厂类：AppleFactory
class AppleFactory(AbstractFactory):
    def phone(self):
        return IPhone()

    def computer(self):
        return MacBook()

# 具体工厂类：MiFactory
class MiFactory(AbstractFactory):
    def phone(self):
        return MIPhone()

    def computer(self):
        return MIBook()

# 客户端代码
def client_code(factory: AbstractFactory):
    computer = factory.computer()
    phone = factory.phone()
    computer.launch()
    phone.launch()

# 使用示例
if __name__ == "__main__":
    print("Client: I'm using the Apple factory.")
    apple_factory = AppleFactory()
    client_code(apple_factory)

    print("\nClient: I'm using the Mi factory.")
    mi_factory = MiFactory()
    client_code(mi_factory)


'''
代码实现：
Client: I'm using the Apple factory.
Launching MacBook
Launching IPhone

Client: I'm using the Mi factory.
Launching MIBook
Launching MIPhone
'''